package fudan.se.project.domain.conference.role;


import fudan.se.project.domain.User;
import fudan.se.project.domain.conference.Conference;
import fudan.se.project.domain.conference.Topic;
import fudan.se.project.domain.conference.production.ReviewInfo;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

@Entity
@Setter
@Getter
@NoArgsConstructor
public class PcMember extends ConferenceRole {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne
    private User user;

    @ManyToOne
    private Conference conference;

    @ManyToMany(fetch = FetchType.LAZY)
    private Set<Topic> topics = new HashSet<>();

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "pcMember")
    private Set<ReviewInfo> reviewInfos = new HashSet<>();

    public PcMember(User user, Conference conference) {
        this.user = user;
        this.conference = conference;
    }

    public void addTopics(Collection<Topic> topicCollection) {
        this.topics.addAll(topicCollection);
    }

}
